<?

class Task2Testing extends CWidget{
    
    public $ulClass = 'tasktesting';
    public $liClass = 'task';
    public $listTitle = 'Нужно проверить';
    
    public function init(){
        
    }
    
    public function run(){
        $criteria = new CDbCriteria;
        $criteria->addColumnCondition(array(
            'user_id'=>Yii::app()->user->id,
            'status'=>Task::model()->rstatuses[TaskModule::t('fields', 'Ожидает проверки')],
        ));
        $criteria->limit = '10';
        $TASKS = Task::model()->with('project')->findAll($criteria);
        if(!empty($TASKS)){
            echo CHtml::tag('b', array(), $this->listTitle);
            echo CHtml::openTag('ul', array('class'=>$this->ulClass));
            foreach($TASKS as $TASK){
                $PROJECT = $TASK->getRelated('project');
                $url = Yii::app()->createUrl('/task/task/list', array('project'=>$PROJECT->code,'tid'=>$TASK->id));
                echo CHtml::tag(
                    'li',
                    array('class'=>$this->liClass),
                    CHtml::link(substr_word(strip_tags($TASK->text)), $url)
                );
            }
            echo CHtml::closeTag('ul');
        }
    }
    
}
